define(function(require, exports, module) {
    var router = require("router");
    //var app = require("app");
    var controller = {};
    controller.vue = function(params) {
        controller.vm = new Vue({
            router: router,
            data: function data() {
                return {
                    user_info: {
                        community:{},
                        tenement_type:[]
                    },
                  
                    page: 1,
                    lastPage:0,
                    mounted: 0,
                    room_info: {},
                    showNoData:0,
                    bills_list:[],
                    nodata:0,
                      shop_id:0,
                      status:'',
                    shop_info:{},
                    bill_amount:"0.00"
                };
            },
            el: "#pageProviderShopbill",
            created: function created() {
                 this.shop_id = this.$route.params.shop_id;
                // this.getShopInfo();
                
                this.getBillList();
            },

            mounted: function mounted() {
                    if (this.mounted == 1) {
                        return;
                    }
                     var that = this ;
                    app.pager("#pageBillsRecords",function(){
                       that.getBillList();
                    });
                    this.mounted = 1;
                    
                     
            },
            methods: {
                    
                setStatus:function(status){
                  // this.bills_list=[];
                  this.status = status;
                  this.getBillList(1);
                },
                 
                getBillList:function(reload=0){
                   if(reload==1){
                      this.setData({ page: 1, loading: 0, bills_list: [],lastPage:0,nodata:0 });
                   }
                   var that = this;
                   var page = this.page;
                   if(that.lastPage==1 || this.loading==1){
                    return ;
                   }
                   var params = {
                     
                      page:page,
                      limit: 20
                     };
                     if(this.status !==""){
                       params.status = this.status;
                     }
                   this.loading = 1;
                    app.get("/mall/shop_bills/get",params,function(res){
                         if(res.code!=200){
                             app.alert(res.msg);
                         }
                         // that.bills_list = res.data.list;
                        if (res.data.list.length === 0) {
                          that.lastPage=1;
                        }

                      page++;
                      if (res.data.list.length>0) {
                        that.setData({ page: page, loading: 0, 'bills_list': that.bills_list.concat(res.data.list) });

                      }
                       if (that.bills_list.length === 0) {
                          that.nodata=1;
                       }else{
                         that.nodata=0;
                       }
                      
                        
                    });
                },
                 
                setData:function(data){
                     for(var i in data){
                        this[i]=data[i];
                     }
                  },
                   
              }
        }).$mount("#app");
    };
    controller.pageShow = function() {};
    module.exports = controller;
});
